Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD MAC label support (initial version) #42

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

priitj
Copy link

@priitj priitj commented Jun 17, 2013

Basic support for MAC labels. Label data is stored in archive in text form as xattrs. Behaviour is exactly like xattrs, archive silently by default, extract when explicitly requested.

There are a few obvious ways of making the code more efficient/robust 1. call mac_is_present() once per program invocation and remember the result 2. do text processing of labels to handle each policy separately (each label can contain grade data for multiple policies). Those ideas are not implemented as I decided not to make things more complex without feedback/pointers from people closely involved with MAC development.

@priitj
Copy link
Author

priitj commented Jun 20, 2013

mac_is_present() has been replaced with a sysctl call instead. The problem is that the former only checks for the presence of the security.mac variable that seems to be there always. security.mac.labeled is non-zero if some policy is labeling some type of objects, which is closer to what we're interested in.

@kientzle
Copy link
Contributor

Quick Note: I haven't forgotten about this. I've started looking through it finally; it looks good so far. I hope to finish reviewing it sometime next week.

@mmatuska
Copy link
Member

mmatuska commented Feb 2, 2017

I don't like the sysctl approach at all. We are issuing here the same sysctl() call for each file we read. We should avoid sysctl at all. The best approach here is to call mac_get_*() and treat EINVAL as a valid errno telling that MAC is not supported for the archived object.

@mmatuska
Copy link
Member

mmatuska commented Feb 3, 2017

I also dislike using an extended attribute with the name "system.mac". Extended attributes are intended to be used with "real" extended attributes and their correct names (an example for MAC would be e.g. mac_biba). A much better solution is e.g. to extend archive_entry with a mac field. This field will be populated if there is a mac label.

A function archive_entry_mac_clear() could be used to clear MAC metadata and archive_entry_mac_to_text() to read it out. A new attribute for pax tar archives, e.g. LIBARCHIVE.mac could store the text label.

When writing, we need to process every label individually and call mac_is_present() before writing it. Because some of the policies may not be loaded.

@priitj
Copy link
Author

priitj commented Feb 3, 2017

Disclaimer: with three and a half years passed, my memory is rather hazy about this and I also don't do any development on FreeBSD anymore.

Re: first comment, why do you need to avoid using sysctl?

As for the second comment, sounds good to me.

@priitj
Copy link
Author

priitj commented Feb 3, 2017

After some reflection, I also probably agree with your first comment, however I won't fix this myself as I don't have a proper test environment for this.

The way it was originally intended was to check the presence of a labelling MAC policy once per program invocation. I guess I should have stated very clearly in comments that the patch was left in unfinished state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants